package com.jht.pj.sys.controller;

import com.jht.pj.sys.service.AdminService;
import com.jht.pj.sys.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class MemberController {
    @Autowired
    private MemberService memberService;
    /*用户登录*/
    @GetMapping("/doMember")
    public String doMember(){

        return "Member";
    }
    @PostMapping("/doMemberObject")
    public String doMemberObject(@RequestParam String username,
                                @RequestParam String password,
                                Model model){
        String result= memberService.memberloginObject(username, password);
        model.addAttribute("result", result);
        return "Member";
    }
    /*用户注册*/
    @PostMapping("/doMember2")
    public String doMember2(){
        return "Member_add";
    }
    @PostMapping("/doMemberObject2")
    public String doMemberObject2(@RequestParam("username") String username,
                                  @RequestParam("password") String password,
                                  Model model
                                    ){
        String result2=memberService.memberlogonObject(username, password);
        model.addAttribute("result2",result2);
            return "Member_add";
    }

    /*用户找回密码*/
    @PostMapping("/doMemberFind")
    public String doMemberFind(){
        return "Member_find";
    }
    @PostMapping("/doMemberFindObject")
    public String doMemberFindObject(@RequestParam("name") String name,
                                    Model model){
        String result03=memberService.memberfindObject(name);
        model.addAttribute("result03",result03);
        return "Member_find";
    }

}
